LEADTOOLS Image Processing (Leadtools.ImageProcessing.Core assembly)

WindowLevelCommand Constructor(Int32,Int32,RasterColor[],RasterByteOrder)

Show in webframe
Example 







Value indicating the low bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).
Value indicating the high bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).
Optional 8-bit lookup table that can be used to implement a user defined conversion. For every intensity value between 0 and 2 raised to the power of (highBit - lowBit + 1) - 1 there should be a corresponding entry in the lookup table that contains an RGB quad. If lookupTable is null, the conversion is a normal shift (right or left) and the output image is 8-bit grayscale. If lookupTable is not null, the output image is a 24-bit image.
Value indicating the color order if the output image will be 24-bit. If LookupTable is null, this parameter is ignored.
Initializes a new WindowLevelCommand class object with explicit parameters.
Syntax
public WindowLevelCommand( 
   int lowBit,
   int highBit,
   RasterColor[] lookupTable,
   RasterByteOrder order
)
'Declaration
 
Public Function New( _
   ByVal lowBit As Integer, _
   ByVal highBit As Integer, _
   ByVal lookupTable() As RasterColor, _
   ByVal order As RasterByteOrder _
)
'Usage
 
Dim lowBit As Integer
Dim highBit As Integer
Dim lookupTable() As RasterColor
Dim order As RasterByteOrder
 
Dim instance As New WindowLevelCommand(lowBit, highBit, lookupTable, order)
public WindowLevelCommand( 
   int lowBit,
   int highBit,
   RasterColor[] lookupTable,
   RasterByteOrder order
)
- (id)initWithLookupTable:(NSArray*)lookupTable 
                   lowBit:(int)lowBit 
                  highBit:(int)highBit 
                    order:(LTRasterByteOrder)order;
            
public WindowLevelCommand(
   int lowBit, 
   int highBit, 
   RasterColor[] lookupTable, 
   RasterByteOrder order
)
            
function WindowLevelCommand( 
   lowBit ,
   highBit ,
   lookupTable ,
   order 
)
public:
WindowLevelCommand( 
   int lowBit,
   int highBit,
   array<RasterColor>^ lookupTable,
   RasterByteOrder order
)

Parameters

lowBit
Value indicating the low bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).
highBit
Value indicating the high bit used for leveling. 0 <= lowBit <= highBit <= (11 for 12-bit grayscale or 15 for 16-bit grayscale).
lookupTable
Optional 8-bit lookup table that can be used to implement a user defined conversion. For every intensity value between 0 and 2 raised to the power of (highBit - lowBit + 1) - 1 there should be a corresponding entry in the lookup table that contains an RGB quad. If lookupTable is null, the conversion is a normal shift (right or left) and the output image is 8-bit grayscale. If lookupTable is not null, the output image is a 24-bit image.
order
Value indicating the color order if the output image will be 24-bit. If LookupTable is null, this parameter is ignored.
Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core

Public Sub WindowLevelConstructorExample()
   Dim codecs As New RasterCodecs()
   codecs.ThrowExceptionsOnInvalidImages = True

   Dim leadImage As RasterImage = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"))

   ' Prepare the command
   'Change the image to 16-bit grayscale
   Dim graycommand As GrayscaleCommand = New GrayscaleCommand(16)
   graycommand.Run(leadImage)

   Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand
   MinMaxBits.Run(leadImage)

   Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand
   MinMaxValues.Run(leadImage)

   Dim Size As Integer = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1))
   Dim LookupTable() As RasterColor
   ReDim LookupTable(Size - 1)
   ' fill the first half of the LookupTable with RED.
   Dim x As Integer
   For x = 0 To (Size \ 2 - 1)
      LookupTable(x) = New RasterColor(255, 0, 0)
   Next
   ' fill the rest with gray values.
   For x = Size \ 2 To Size - 1
      Dim y As Byte = CType((x) * 255 / (Size), Byte)
      LookupTable(x) = New RasterColor(y, y, y)
   Next

   Dim command As WindowLevelCommand = New WindowLevelCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr)
   command.Run(leadImage)

End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;

public void WindowLevelConstructorExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;

   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "Master.jpg"));

   // Prepare the command
   //Change the image to 16-bit grayscale
   GrayscaleCommand graycommand = new GrayscaleCommand(16);
   graycommand.Run(image);

   MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand();
   MinMaxBits.Run(image);

   MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand();
   MinMaxValues.Run(image);

   int Size = (1 <<(MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1));
   RasterColor [] LookupTable = new RasterColor[Size];

   // fill the first half of the LookupTable with RED.
   for(int x = 0; x < Size / 2; x++)
      LookupTable[x] = new RasterColor(255, 0, 0);

   // fill the rest with gray values.
   for(int x = Size / 2; x < Size; x++)
   {
      byte y = (byte)((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue));
      LookupTable[x] = new RasterColor(y, y, y);
   }

   WindowLevelCommand command = new WindowLevelCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr);

   command.Run(image);

}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
function WindowLevelConstructorExample()
{
   var codecs = new Leadtools.Codecs.RasterCodecs();
   codecs.throwExceptionsOnInvalidImages = true;

   // Load the image
   var srcFileName = "Assets\\Image1.cmp";
   var processedImage;
   return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) {
      return codecs.loadAsync(Leadtools.LeadStreamFactory.create(loadFile));
   }).then(function (image) {
      // Prepare the command
      with (Leadtools.ImageProcessing.Core) {
         //Change the image to 16-bit grayscale
         var graycommand = new GrayscaleCommand(16);
         graycommand.run(image);
         
         var MinMaxBits = new MinMaxBitsCommand();
         MinMaxBits.run(image);
         
         var MinMaxValues = new MinMaxValuesCommand();
         MinMaxValues.run(image);
         
         var Size = (1 <<(MinMaxBits.maximumBit - MinMaxBits.minimumBit + 1));
         var LookupTable = new Array();
         
         // fill the first half of the LookupTable with RED.
         for(var x = 0; x < Size / 2; x++)
            LookupTable[x] = Leadtools.RasterColorHelper.create(255, 0, 0);
         
         // fill the rest with gray values.
         for(var x = Size / 2; x < Size; x++)
         {
            var y = (x - MinMaxValues.minimumValue) * 255 / (MinMaxValues.maximumValue - MinMaxValues.minimumValue);
            LookupTable[x] = Leadtools.RasterColorHelper.create(y, y, y);
         }
         
         var command = new WindowLevelCommand(MinMaxBits.minimumBit, MinMaxBits.maximumBit, LookupTable, RasterByteOrder.bgr);
         
         command.run(image);
      }
   });
}
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing.Core;
using Leadtools.ImageProcessing;

      
public async Task WindowLevelConstructorExample()
{
   // Load an image
   RasterCodecs codecs = new RasterCodecs();
   codecs.ThrowExceptionsOnInvalidImages = true;
   // Load the image
   string srcFileName = @"Assets\Image1.cmp";
   StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName);
   RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile));

   // Prepare the command
   //Change the image to 16-bit grayscale
   GrayscaleCommand graycommand = new GrayscaleCommand(16);
   graycommand.Run(image);

   MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand();
   MinMaxBits.Run(image);

   MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand();
   MinMaxValues.Run(image);

   int Size = (1 <<(MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1));
   RasterColor [] LookupTable = new RasterColor[Size];

   // fill the first half of the LookupTable with RED.
   for(int x = 0; x < Size / 2; x++)
      LookupTable[x] = RasterColorHelper.Create(255, 0, 0);

   // fill the rest with gray values.
   for(int x = Size / 2; x < Size; x++)
   {
      byte y = (byte)((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue));
      LookupTable[x] = RasterColorHelper.Create(y, y, y);
   }

   WindowLevelCommand command = new WindowLevelCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr);

   command.Run(image);

}
using Leadtools;
using Leadtools.Examples;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Core;

public void WindowLevelConstructorExample(RasterImage image, Stream outStream)
{
   // Prepare the command
   //Change the image to 16-bit grayscale
   GrayscaleCommand graycommand = new GrayscaleCommand(16);
   graycommand.Run(image);
   MinMaxBitsCommand MinMaxBits = new MinMaxBitsCommand();
   MinMaxBits.Run(image);

   MinMaxValuesCommand MinMaxValues = new MinMaxValuesCommand();
   MinMaxValues.Run(image);

   int Size = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1));
   RasterColor[] LookupTable = new RasterColor[Size];

   // fill the first half of the LookupTable with RED.
   for (int x = 0; x < Size / 2; x++)
      LookupTable[x] = new RasterColor(255, 0, 0);

   // fill the rest with gray values.
   for (int x = Size / 2; x < Size; x++)
   {
      byte y = (byte)((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue));
      LookupTable[x] = new RasterColor(y, y, y);
   }

   WindowLevelCommand command = new WindowLevelCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr);

   command.Run(image);
   // Save result image
   RasterCodecs codecs = new RasterCodecs();
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24);
   image.Dispose();
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Core

Public Sub WindowLevelConstructorExample(ByVal image As RasterImage, ByVal outStream As Stream)
   ' Prepare the command
   'Change the image to 16-bit grayscale
   Dim graycommand As GrayscaleCommand = New GrayscaleCommand(16)
   graycommand.Run(image)
   Dim MinMaxBits As MinMaxBitsCommand = New MinMaxBitsCommand()
   MinMaxBits.Run(image)

   Dim MinMaxValues As MinMaxValuesCommand = New MinMaxValuesCommand()
   MinMaxValues.Run(image)

   Dim Size As Integer = (1 << (MinMaxBits.MaximumBit - MinMaxBits.MinimumBit + 1))
   Dim LookupTable As RasterColor() = New RasterColor(Size - 1){}

   ' fill the first half of the LookupTable with RED.
   Dim x As Integer = 0
   Do While x < Size / 2
      LookupTable(x) = New RasterColor(255, 0, 0)
      x += 1
   Loop

   ' fill the rest with gray values.
   x = Size / 2
   Do While x < Size
      Dim y As Byte = CByte((x - MinMaxValues.MinimumValue) * 255 / (MinMaxValues.MaximumValue - MinMaxValues.MinimumValue))
      LookupTable(x) = New RasterColor(y, y, y)
      x += 1
   Loop

   Dim command As WindowLevelCommand = New WindowLevelCommand(MinMaxBits.MinimumBit, MinMaxBits.MaximumBit, LookupTable, RasterByteOrder.Bgr)

   command.Run(image)
   ' Save result image
   Dim codecs As RasterCodecs = New RasterCodecs()
   codecs.Save(image, outStream, RasterImageFormat.Jpeg, 24)
   image.Dispose()
End Sub
Requirements

Target Platforms

See Also

Reference

WindowLevelCommand Class
WindowLevelCommand Members
Overload List

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.